Skip to content

Cleanup: Connection cancel -> shutdown #404

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 23, 2021

Conversation

fabianfett
Copy link
Member

Motivation

  • It is unclear what it means to cancel a connection

Modifications

  • Rename cancel connection to shutdown, with an explicit code comment
  • Add .http1_1 and .http2 cases to HTTPConnectionPool.Connection

@fabianfett fabianfett requested review from glbrntt and Lukasa July 23, 2021 08:07
@fabianfett fabianfett changed the title Cleanup: Cancel -> Shutdown Cleanup: Connection cancel -> shutdown Jul 23, 2021
@fabianfett fabianfett added the 🔨 semver/patch No public API change. label Jul 23, 2021
@fabianfett fabianfett added this to the HTTP/2 support milestone Jul 23, 2021
Copy link
Collaborator

@glbrntt glbrntt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Comment on lines 66 to 68
return connection.execute(request: request)
case .http2(let connection):
return connection.executeRequest(request)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's some mildly irritating asymmetry :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

case .__testOnly_connection:
break
}
}

fileprivate func cancel() {
/// Closes the connection without cancelling running requests.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens to the requests if we don't cancel them? Why would do use this over shutdown?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the pool state machine, we know if a connection is idle or not. For this reason, we can use the direct way to close, if we are sure nothing is running on the connection.

@Lukasa Lukasa merged commit 44efb94 into swift-server:main Jul 23, 2021
@fabianfett fabianfett deleted the ff-cleanup-shutdown branch July 23, 2021 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 semver/patch No public API change.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants